﻿using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;

namespace ProjScan.Config
{
	// Token: 0x02000320 RID: 800
	internal class ArtAssetsCheckConfig : BaseConfig
	{
		// Token: 0x060012BD RID: 4797 RVA: 0x00059528 File Offset: 0x00057728
		public override void Init()
		{
			this.hasSeparateTargetDirSettings = true;
			this.hasfailedData = true;
			this.hasWhiteList = true;
			this.hasFixRule = true;
			bool flag = this.dicRuleConfig == null;
			if (flag)
			{
				this.dicRuleConfig = new Dictionary<string, RuleConfig>();
			}
			else
			{
				this.dicRuleConfig.Clear();
			}
			this.improperPivotPosTolerance = 0.4f;
			this.faceTexDensityMinSqrtDensity = 128f;
			this.faceTexDensityMaxVariance = 1000f;
			this.uvRangeMaxUVRange = 16f;
			this.vertexDensityMaxDensity = 50f;
			this.vertexDensityDistance = 30f;
			this.vertexDensityFov = 60f;
			this.hardedgeUVSeamThreshold = 32;
			this.uvPaddingThreshold = 4;
		}

		// Token: 0x060012BE RID: 4798 RVA: 0x00008CD7 File Offset: 0x00006ED7
		public override void LoadConfig(JObject data)
		{
			this._rootConfig = (JObject)data["Art_Assets_Check"];
			this.ResolveRule();
			this.SetPropertyValuesByRuleConfig();
		}

		// Token: 0x060012BF RID: 4799 RVA: 0x00008CFE File Offset: 0x00006EFE
		public override void SaveConfig(JObject data)
		{
			data.Add("Art_Assets_Check", this.SaveJObjectRule());
		}

		// Token: 0x060012C0 RID: 4800 RVA: 0x000595D8 File Offset: 0x000577D8
		private void SetPropertyValuesByRuleConfig()
		{
			this.improperPivotPosTolerance = this.GetRuleConfigValueAsFloat("ArtAssets.Mesh.ImproperPivotPos", "tolerance");
			this.faceTexDensityMinSqrtDensity = this.GetRuleConfigValueAsFloat("ArtAssets.Prefab.FaceTexDensityAvgTooSmall", "minSqrtDensity");
			this.faceTexDensityMaxVariance = this.GetRuleConfigValueAsFloat("ArtAssets.Prefab.FaceTexDensityVrcTooLarge", "maxVariance");
			this.uvRangeMaxUVRange = this.GetRuleConfigValueAsFloat("ArtAssets.Mesh.UVRangeTooLarge", "maxUVRange");
			this.vertexDensityMaxDensity = this.GetRuleConfigValueAsFloat("ArtAssets.Mesh.VertexDensityTooLarge", "maxDensity");
			this.vertexDensityDistance = this.GetRuleConfigValueAsFloat("ArtAssets.Mesh.VertexDensityTooLarge", "distance");
			this.vertexDensityFov = this.GetRuleConfigValueAsFloat("ArtAssets.Mesh.VertexDensityTooLarge", "fov");
			this.hardedgeUVSeamThreshold = this.GetRuleConfigValueAsInt("ArtAssets.Mesh.HardedgeUVSeamThreshold", "threshold");
			this.uvPaddingThreshold = this.GetRuleConfigValueAsInt("ArtAssets.Mesh.UVPaddingTooSmall", "threshold");
		}

		// Token: 0x060012C1 RID: 4801 RVA: 0x000596AC File Offset: 0x000578AC
		private float GetRuleConfigValueAsFloat(string ruleID, string propertyName)
		{
			JObject jobject = (JObject)this._rootConfig["Rule_List"];
			RuleConfig ruleConfig;
			bool flag = this.dicRuleConfig.TryGetValue(ruleID, out ruleConfig) && jobject != null;
			if (flag)
			{
				bool flag2 = jobject[ruleConfig.ruleKey] != null && jobject[ruleConfig.ruleKey][propertyName] != null;
				if (flag2)
				{
					return Extensions.Value<float>(jobject[ruleConfig.ruleKey][propertyName]);
				}
			}
			return 0f;
		}

		// Token: 0x060012C2 RID: 4802 RVA: 0x00059740 File Offset: 0x00057940
		private int GetRuleConfigValueAsInt(string ruleID, string propertyName)
		{
			JObject jobject = (JObject)this._rootConfig["Rule_List"];
			RuleConfig ruleConfig;
			bool flag = this.dicRuleConfig.TryGetValue(ruleID, out ruleConfig) && jobject != null;
			if (flag)
			{
				bool flag2 = jobject[ruleConfig.ruleKey] != null && jobject[ruleConfig.ruleKey][propertyName] != null;
				if (flag2)
				{
					return Extensions.Value<int>(jobject[ruleConfig.ruleKey][propertyName]);
				}
			}
			return 0;
		}

		// Token: 0x04000B1A RID: 2842
		public float improperPivotPosTolerance = 0.4f;

		// Token: 0x04000B1B RID: 2843
		public float faceTexDensityMinSqrtDensity = 128f;

		// Token: 0x04000B1C RID: 2844
		public float faceTexDensityMaxVariance = 1000f;

		// Token: 0x04000B1D RID: 2845
		public float uvRangeMaxUVRange = 16f;

		// Token: 0x04000B1E RID: 2846
		public float vertexDensityMaxDensity = 50f;

		// Token: 0x04000B1F RID: 2847
		public float vertexDensityDistance = 30f;

		// Token: 0x04000B20 RID: 2848
		public float vertexDensityFov = 60f;

		// Token: 0x04000B21 RID: 2849
		public int hardedgeUVSeamThreshold = 32;

		// Token: 0x04000B22 RID: 2850
		public int uvPaddingThreshold = 4;
	}
}
